#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2025/10/24 22:30
# @Author  : summer
# @Email   : 610658552@qq.com
# @File    : prd.py
# @Software: PyCharm
# @Desc    :
# ----------------------- settings
LANGUAGE_CODE = 'zh-hans'
TIME_ZONE = 'Asia/Shanghai'
USE_I18N = True
USE_TZ = False
# ------------------------短信---------------
# 阿里云-- 聪明掌柜
SMS_KEY = "LTAI5tQSwLqRCT6aMi7ghdkB"
SMS_SECRET = "DvH2Ey5FDy8an9lJpbUbfbk20fmYbq"
# 2. 签名
SMS_SIGN = "聪明掌柜"
# 3. 商家注册
SMS_TEMPLATE_CUSTOMSER_REG = 'SMS_460755411'


# MySQLdb driver confi
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'push',
        'USER': 'root',
        'PASSWORD': 'root',
        'HOST': '127.0.0.1',
        'PORT': '3306',
    }
}

# token
JWT_TOKEN = 'django-insecure-jtm-an+4-@)$xn27km(va+sljr8p8wz8+@%4t5gkuab^!zt6qi'

# rest_framework config
REST_FRAMEWORK = {
    "DEFAULT_AUTHENTICATION_CLASSES": [
        "common.ext.auth.JwtQueryParamsAuthentication",
        "common.ext.auth.JwtHeaderAuthentication",
        "common.ext.auth.JwtBodyAuthentication",
        "common.ext.auth.NoAuthentication",
    ],
    # 全局分页：所有列表接口自动分页
    'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
    "EXCEPTION_HANDLER": "common.utils.exception_handler.custom_exception_handler",
    'PAGE_SIZE': 10,  # 默认每页记录数
    'PAGE_SIZE_QUERY_PARAM': 'page_size',  # 每页记录数参数名
    'MAX_PAGE_SIZE': 100,  # 最大每页记录数
    'DEFAULT_FILTER_BACKENDS': [
        'django_filters.rest_framework.DjangoFilterBackend'
    ]
}
# 跨域配置
CORS_ALLOW_ALL_ORIGINS = True
# CORS_ALLOWED_ORIGINS = [
#     "https://www.example.com",
#     "http://localhost:8080",
#     "http://127.0.0.1:9000",
# ]
# 允许的请求方法
CORS_ALLOW_METHODS = [
    'DELETE',
    'GET',
    'OPTIONS',
    'PATCH',
    'POST',
    'PUT',
]
# 允许的请求头
CORS_ALLOW_HEADERS = [
    'accept',
    'accept-encoding',
    'authorization',
    'content-type',
    'dnt',
    'origin',
    'user-agent',
    'x-csrftoken',
    'x-requested-with',
]
# 是否允许携带Cookie
CORS_ALLOW_CREDENTIALS = True  # 如果前端需要传cookie/token

# 预检请求缓存时间（秒）
CORS_PREFLIGHT_MAX_AGE = 86400

# 文件大小限制（示例：10MB）
DATA_UPLOAD_MAX_MEMORY_SIZE = 1024 * 1024 * 10
FILE_UPLOAD_MAX_MEMORY_SIZE = DATA_UPLOAD_MAX_MEMORY_SIZE
